<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>Markdown编辑器</title>
</head>
<!-- layui样式 -->
<link rel="stylesheet" href="/components/editor/css/editormd.css">
<script src="/base/js/app.js"></script>
<script src='/base/js/jquery-3.4.1.min.js'></script>
<script type="text/javascript" src="/components/editor/editormd.js"></script>
<!-- 图片粘贴复制拖拽，Markdown编辑器元素  textarea id必须为 L_content，并且该引入必须在 textarea的下方，否则无法读取到 L_content 参数 -->
<script src="/components/editor/imgCopyPull2.js"></script>

<body>
<div id="L_content"></div>
<script>
    //注意1：这里的就是上面的DIV的id属性值
    var myEditor = editormd("L_content", {
        width: "90%",
        height: 640,
        syncScrolling: "single",
        path: "/components/editor/lib/",// 资源路径
        // 自定义的增强配置！
        saveHTMLToTextarea: true,        // 保存 HTML 到 Textarea
        emoji: true, // 开启表情的功能！ 图片的本地配置！
        // theme: "light",               // 工具栏主题
        // previewTheme: "dark",         // 预览主题
        // editorTheme: "pastel-on-dark",// 编辑主题
        // markdown的配置！
        tex: true,                   // 开启科学公式TeX语言支持，默认关闭
        flowChart: true,             // 开启流程图支持，默认关闭
        sequenceDiagram: true,       // 开启时序/序列图支持，默认关闭,
        imageUpload: false,          // 图片本地上传,禁用，使用imgCopyPull2.js 的上传方式
        /*指定需要显示的功能按钮*/
        toolbarIcons : function() {
            return ["undo","redo","|",
                "bold","del","italic","quote","ucwords","uppercase","lowercase","|",
                // "h1","h2","h3","h4","h5","h6","|",
                "list-ul","list-ol","hr","|",
                "link","reference-link","image","code","preformatted-text",
                "code-block","table","datetime","emoji","html-entities","pagebreak","|",
                "goto-line","watch","preview","fullscreen","clear","search","|",
                "help","info","|",
                "releaseIcon", "index"]
        },
        /*自定义功能按钮，下面我自定义了2个，一个是发布，一个是返回首页*/
        toolbarIconTexts : {
            releaseIcon : "<span bgcolor=\"gray\">发布文章</span>",
           // index : "<span bgcolor=\"red\">返回首页</span>",
        },
        /*给自定义按钮指定回调函数*/
        toolbarHandlers:{
            releaseIcon : function(cm, icon, cursor, selection) {
                //表单提交
                // myEditor.method = "post";
                // myEditor.action = "/article/addArticle";//提交至服务器的路径
                // myEditor.submit();
                alert("发布")
            },
            // index : function(){
            //     // window.location.href = '/';
            //     alert("返回首页")
            // },
        }
    });
</script>
</body>
</html>
